<!--
 @description 经销商收货地址
 @fileName Address.vue
 @author zengqiongying
 @created 2023/04/28 13:54:59
-->
<template>
  <div>
    <Card v-for="(item, i) in list" :key="`${i}-${item.code}`">
      <template #title>
        <div class="card-header">
          <span class="name"><span class="icon"></span>{{ item.code }} {{ item.name }}</span>
        </div>
      </template>
      <AddressItem :modelValue="item" hide-name />
    </Card>
  </div>
</template>

<script lang="ts">
  import { reactive, toRefs, getCurrentInstance, nextTick } from 'vue'
  import { useRouter, useRoute } from 'vue-router'
  import Card from '@/components/Card/index.vue'
  import AddressItem from '../../components/Address/ItemView.vue'
  import { detail } from '@/apis/dealerMarketing/Customer'
  const none: any[] = [null, undefined, '']
  export default {
    name: 'DealerCustomerAddress',
    components: { Card, AddressItem },
    setup() {
      const { proxy }: any = getCurrentInstance()
      const $router = useRouter()
      const $route = useRoute()
      const datas = reactive({
        code: $route.query.code || '',
        list: []
      })

      const getList = () => {
        const code = `${datas.code}`
        detail(code).then((res: any) => {
          datas.list = res.data?.customerAddressDTOS || []
        })
      }
      getList()

      return {
        ...toRefs(datas)
      }
    }
  }
</script>
<style lang="less" scoped>
  @import url('../../styles/common.less');
</style>
